fix(types): remove void from SharedRenderProps.component union - #4079
fix(types): remove void from SharedRenderProps.component union#4079ErfanBagheri404 wants to merge 1 commit into
Conversation
The `component` prop always receives the same render props as `render` /
`children` at runtime (same props object passed to `createElement`), so there
is no code path where it gets `void`. The `ComponentType<T | void>` union
forces false type errors when passing a properly-typed `React.FC<T>` component
to `<FieldArray component={...} />` and similar.
Closes jaredpalmer#4061
|
@ErfanBagheri404 is attempting to deploy a commit to the Formik Team on Vercel. A member of the Team first needs to authorize it. |
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Summary
SharedRenderProps.component was typed as React.ComponentType<T | void>, but at runtime the component prop always receives the same props as render/children (same object passed to createElement) -- no code path gives it void. The void union forces false type errors when passing a properly-typed React.FC.
Changes
Removed void from the ComponentType union in packages/formik/src/types.tsx.
Type
Type-only change: keyof React.JSX.IntrinsicElements | React.ComponentType, matching render/children.
Closes #4061